package com.example.springbatchdemo.config.decider;

import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.job.flow.FlowExecutionStatus;
import org.springframework.batch.core.job.flow.JobExecutionDecider;
import org.springframework.stereotype.Component;

/**
 * @Classname MyDecider
 * @Description 决策器的具体实现
 * @Date 2020/9/19 12:42
 * @Created by kevin
 */
@Component
public class MyDecider implements JobExecutionDecider {


    private int count;

    @Override
    public FlowExecutionStatus decide( JobExecution jobExecution, StepExecution stepExecution ) {

        count++;
        if (count % 2 == 0) {
            return new FlowExecutionStatus("even");
        } else {
            return new FlowExecutionStatus("odd");
        }

    }
}
